/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package cse.om.data;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 *
 * @author hungl_000
 */
@Entity
@Table(name = "Comment", catalog = "Facebook", schema = "dbo")
@NamedQueries({
	@NamedQuery(name = "Comment.findAll", query = "SELECT c FROM Comment c"),
	@NamedQuery(name = "Comment.findById", query = "SELECT c FROM Comment c WHERE c.id = :id"),
	@NamedQuery(name = "Comment.findByContent", query = "SELECT c FROM Comment c WHERE c.content = :content"),
	@NamedQuery(name = "Comment.findBySource", query = "SELECT c FROM Comment c WHERE c.source = :source"),
	@NamedQuery(name = "Comment.findByFromUserId", query = "SELECT c FROM Comment c WHERE c.fromUserId = :fromUserId"),
	@NamedQuery(name = "Comment.findByToUserId", query = "SELECT c FROM Comment c WHERE c.toUserId = :toUserId"),
	@NamedQuery(name = "Comment.findByOwnerUserId", query = "SELECT c FROM Comment c WHERE c.ownerUserId = :ownerUserId"),
	@NamedQuery(name = "Comment.findByTime", query = "SELECT c FROM Comment c WHERE c.time = :time")})
public class Comment implements Serializable {
	@Transient
	private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
	private static final long serialVersionUID = 1L;
	@Id
    @Basic(optional = false)
    @Column(name = "Id")
	private String id;
	@Column(name = "Content")
	private String content;
	@Column(name = "Source")
	private String source;
	@Basic(optional = false)
    @Column(name = "FromUserId")
	private long fromUserId;
	@Basic(optional = false)
    @Column(name = "ToUserId")
	private long toUserId;
	@Basic(optional = false)
    @Column(name = "OwnerUserId")
	private long ownerUserId;
	@Basic(optional = false)
    @Column(name = "Time")
	private String time;

	public Comment() {
	}

	public Comment(String id) {
		this.id = id;
	}

	public Comment(String id, long fromUserId, long toUserId, long ownerUserId, String time) {
		this.id = id;
		this.fromUserId = fromUserId;
		this.toUserId = toUserId;
		this.ownerUserId = ownerUserId;
		this.time = time;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		String oldId = this.id;
		this.id = id;
		changeSupport.firePropertyChange("id", oldId, id);
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		String oldContent = this.content;
		this.content = content;
		changeSupport.firePropertyChange("content", oldContent, content);
	}

	public String getSource() {
		return source;
	}

	public void setSource(String source) {
		String oldSource = this.source;
		this.source = source;
		changeSupport.firePropertyChange("source", oldSource, source);
	}

	public long getFromUserId() {
		return fromUserId;
	}

	public void setFromUserId(long fromUserId) {
		long oldFromUserId = this.fromUserId;
		this.fromUserId = fromUserId;
		changeSupport.firePropertyChange("fromUserId", oldFromUserId, fromUserId);
	}

	public long getToUserId() {
		return toUserId;
	}

	public void setToUserId(long toUserId) {
		long oldToUserId = this.toUserId;
		this.toUserId = toUserId;
		changeSupport.firePropertyChange("toUserId", oldToUserId, toUserId);
	}

	public long getOwnerUserId() {
		return ownerUserId;
	}

	public void setOwnerUserId(long ownerUserId) {
		long oldOwnerUserId = this.ownerUserId;
		this.ownerUserId = ownerUserId;
		changeSupport.firePropertyChange("ownerUserId", oldOwnerUserId, ownerUserId);
	}

	public String getTime() {
		return time;
	}

	public void setTime(String time) {
		String oldTime = this.time;
		this.time = time;
		changeSupport.firePropertyChange("time", oldTime, time);
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (id != null ? id.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals(Object object) {
		// TODO: Warning - this method won't work in the case the id fields are not set
		if (!(object instanceof Comment)) {
			return false;
		}
		Comment other = (Comment) object;
		if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "cse.om.gui.Comment[ id=" + id + " ]";
	}

	public void addPropertyChangeListener(PropertyChangeListener listener) {
		changeSupport.addPropertyChangeListener(listener);
	}

	public void removePropertyChangeListener(PropertyChangeListener listener) {
		changeSupport.removePropertyChangeListener(listener);
	}
	
}
